package com.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.api.common.jwt.TokenIgnore;
import com.api.common.reqres.Request;
import com.api.common.reqres.Response;
import com.api.model.request.AddRoleRequest;
import com.api.model.request.RoleAddMenuRequest;
import com.api.model.request.RoleListRequest;
import com.api.model.request.UpdateRoleRequest;
import com.api.model.response.NullResponse;
import com.api.service.RoleService;

import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 角色
 * </p>
 *
 * @author cfp
 * @since 2019-10-21
 */
@RestController
@TokenIgnore
public class RoleController {
	@Autowired
	private RoleService roleService;

	@ApiOperation(notes = "查询角色列表", value = "查询角色列表")
	@PostMapping(value = "/roleList.do")
	public Response<NullResponse> roleList(@RequestBody Request<RoleListRequest> request) throws Exception {
		return roleService.roleList(request);
	}

	@ApiOperation(notes = "修改角色信息", value = "修改角色信息")
	@PostMapping(value = "/updateRole.do")
	public Response<NullResponse> updateRole(@RequestBody Request<UpdateRoleRequest> request) throws Exception {
		return roleService.updateRole(request);
	}

	@ApiOperation(notes = "增加角色", value = "增加角色")
	@PostMapping(value = "/addRole.do")
	public Response<NullResponse> addRole(@RequestBody Request<AddRoleRequest> request) throws Exception {
		return roleService.addRole(request);
	}

	@ApiOperation(notes = "角色增加菜单", value = "角色增加菜单")
	@PostMapping(value = "/roleAddMenu.do")
	public Response<NullResponse> roleAddMenu(@RequestBody Request<RoleAddMenuRequest> request) throws Exception {
		return roleService.roleAddMenu(request);
	}
}
